<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<!--
  - Application context definition for JPetStore's data access layer.
  - Accessed by business layer objects defined in "applicationContext.xml"
  - (see web.xml's "contextConfigLocation").
  -
  - This version of the data access layer works on a combined database,
  - using a local DataSource with DataSourceTransactionManager. It does not
  - need any JTA support in the container: It will run as-is in plain Tomcat.
  -->
<beans>

	<!-- ========================= RESOURCE DEFINITIONS ========================= -->
	<!-- Configurer that replaces  placeholders with values from properties files  -->
	<!-- (in this case, mail and JDBC related properties) -->
     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
			<!--<value>classpath:mail.properties</value>-->
				<value>classpath:jdbc.properties</value>
			</list>
		</property>
	</bean>
	<#noparse>
	<!-- MailSender used by EmailAdvice -->
	<!--
	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<property name="host" value="${mail.host}"/>
	</bean>
	-->
	</#noparse>
	<!-- Local Apache Commons DBCP DataSource that refers to a combined database -->
	<!-- (see dataAccessContext-jta.xml for an alternative) -->
	<!-- The placeholders are resolved from jdbc.properties through -->
	<!-- the PropertyPlaceholderConfigurer in applicationContext.xml -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="<#noparse>${jdbc.driverClassName}</#noparse>"/>
		<property name="url" value="<#noparse>${jdbc.url}</#noparse>"/>
		<property name="username" value="<#noparse>${jdbc.username}</#noparse>"/>
		<property name="password" value="<#noparse>${jdbc.password}</#noparse>"/>
	</bean>

	<!-- Transaction manager for a single JDBC DataSource -->
	<!-- (see dataAccessContext-jta.xml for an alternative) -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>
	</bean>

	<!-- SqlMap setup for iBATIS Database Layer -->
	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation" value="classpath:SqlMapConfig.xml"/>
		<property name="dataSource" ref="dataSource"/>
	</bean>

</beans>
